#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
int n;
int st[N];
int main()
{
	int t;
	cin >> t;
	//cout << "ans==" << log2(N) << endl;
	for (LL i = 2; i <= 1e6; i++) {
		LL x = i * i * i;
		LL sum = 1 + i + i * i;
		if (sum <= 1e6)st[sum] = 1;
		while (1) {
			sum += x;
			if (sum > 1e6)break;
			//cout << "sum==" << sum << endl;
			//cout << "x==" << x << endl;
			st[sum] = 1;
			x = x * i;
		}	
	}
	while (t--) {
		cin >> n;
		if (st[n])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}